package com.wmx.thread.daemon;

import java.util.concurrent.TimeUnit;

/**********************************
 * @author wmx
 * @date 2019/9/2 11:41
 * @description:
 * @version 1.0
 ************************************/
public class DaemonThread {
    public static void main(String[] args) {
        long timeMillis = System.currentTimeMillis();
        long seconds = timeMillis / 1000;
        Thread thread = new Thread(() ->{
            try {
                TimeUnit.DAYS.sleep(Long.MAX_VALUE);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        });
        thread.setDaemon(false);
        thread.start();
        try {
            TimeUnit.SECONDS.sleep(15);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        long timeMillis1 = System.currentTimeMillis();
        long seconds1 = timeMillis1 / 1000;
        System.out.println("主线程退出，程序执行"+(seconds1-seconds));

    }
}
